/**
 * ContextNode
 *
 * This represents a union of a store object with it's transport details
 * for example, a file name, mime type and url
 *
 * The idea is that front end services (like upnp) only have to deal with a context
 * and context nodes, not content stores and transports
 *
 */
package uk.co.sheitgeist.fums.server.content.context

import uk.co.sheitgeist.fums.server.content.store.*
import uk.co.sheitgeist.fums.server.content.transport.*

public class ContextNode {
	ContextNode parent
	StoreNode storeNode
	Transport transport
	
	public ContextNode(StoreNode storeNode, Transport transport) {
		this.storeNode = storeNode
		this.transport = transport
	}

	public ContextNode(ContextNode parent, StoreNode storeNode, Transport transport) {
		this.parent = parent
		this.storeNode = storeNode
		this.transport = transport
	}

	public Boolean getIsFolder() {
		return this.storeNode.isFolder
	}

	public String getUrl() {
		transport.getUrl(storeNode)
	}

	public List<ContextNode> getDirectChildren() {
		def list = []
		storeNode.children.each { child ->
			list.add(new ContextNode(this, child, this.transport))
		}
		return list

	}

	public String getName() { 
		return this.storeNode.name
	}

	public String getId() {
		return this.storeNode.id
	}

	public String getPrimaryType() {
		return this.storeNode.primaryType
	}
}
